﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;

#endregion

using Weazel.Badger.Vhdl.Types;

namespace Weazel.Badger.Vhdl.Expressions
{
  public class AttributeExpression : Expression
  {
    private IAttribute attribute;

    public AttributeExpression(
			IComponent parentContainer,
			IAttribute attribute
		) 
			: base(parentContainer, attribute.Type, null) // todo: is this right?
    {
      this.attribute = attribute;
    }

    public AttributeExpression(
			IComponent parentContainer,
			IAttribute attribute, 
			Gezel.Model.Expression expression
		) 
			: base(parentContainer, attribute.Type, null, expression)
    {
      this.attribute = attribute;
    }

    public override bool VerifyType(ref List<VerifyMessage> messages)
    {
      throw new NotImplementedException();
    }

    public override TypeSet GetPossibleTypes()
    {
      return new TypeSet(attribute.Type);
    }

		public override void SetActualType(Entity entity, Process process, Statements.StatementCollection statements, Vhdl.Types.Type type)
    {
      if (!type.Compare(attribute.Type))
      {
        string message =
          "SetActualType(): Unusable type";

        throw new NotSupportedException(message);
      }
    }

    public override string ToString()
    {
      return String.Format("{0}' {1}", attribute.ParentName, attribute.Name);
    }
  }
}
